package controler;

import java.security.*;
/**
 * <p>Title: controler.Auth </p>
 *
 * <p>
 * 	Classe donnant acces aux fonctions utiles pour l'authentification
 * </p>
 *
 * <p>Copyright: (c) 2008 FSSIM</p>
 *
 * <p>Company: FSSImock</p>
 *
 * @author Augustin Couette
 * @author Antoine Farnault
 *
 */
public class Auth {
	 private static byte[] hash(byte[] s) throws NoSuchAlgorithmException{
		MessageDigest md;
		md = MessageDigest.getInstance("MD5");
		md.update(s);
		return md.digest();
	 }
	 
	 public static byte[] compute(String seed, String password, int sequence) throws NoSuchAlgorithmException{
		 byte[] m = (seed+password).getBytes();
		 for (int i = 0; i < sequence; i++) {
			 m = hash(m);
		 }
		 return m;
	 }
}
